package org.batatasframework.support.definition;

import java.util.List;

import org.batatasframework.support.database.DatabaseType;
import org.batatasframework.support.database.sql.TableInstance;
import org.batatasframework.support.database.sql.spi.TableCriterion;
import org.batatasframework.support.database.sql.where.QueryFragmentAppender;
import org.batatasframework.support.event.HttpRequestAccessor;
import org.batatasframework.support.searchable.FieldQueryed;

import cn.bonoon.kernel.support.IOperator;
import cn.bonoon.kernel.util.Opt;

/**
 * <pre>
 * 查询字段的定义，被定义的字段可以当作查询条件的选择项，可以在界面进行指定查询过滤的内容，
 * 提交到后面来生成查询条件。
 * </pre>
 * @author jackson
 *
 */
public interface QueryDefinition{
	
	DatabaseType getDataType();
	
	Opt[] getOpts();
	
	String getTitle();
	
	void buildQuery(QueryFragmentAppender queryAppend, TableCriterion tableCriterion, HttpRequestAccessor paramAccessor, String key) throws Exception;
	void buildQuery(QueryFragmentAppender queryAppend, TableInstance tableSource, HttpRequestAccessor paramAccessor, String key) throws Exception;
	
	/**
	 * 生成界面的查询条件选择项
	 * @param queryColumn 返回到界面的对象
	 * @param key 
	 * @param operator
	 * @param forceRefresh 表示不使用缓存，强制刷新生成新的列表对象
	 */
	void buildFieldQueryed(List<FieldQueryed> queryColumn, String key, IOperator operator, boolean forceRefresh);
}
